Source Code Viewer - Example 6 - GameListDisplay

package name.matthewgreet.example6.view;

import name.matthewgreet.example6.action.ViewGameListAction.GameCategory;
import name.matthewgreet.example6.dto.GameDTO;
import name.matthewgreet.example6.util.Example6FormatLibrary;
import name.matthewgreet.strutscommons.util.ListCache;
import name.matthewgreet.strutscommons.view.AbstractListDisplay;

public class GameListDisplay extends AbstractListDisplay<GameDisplay,GameDTO> {
	
	private GameCategory preferredCategory;
	private String preferredRankName;
	private boolean noSelectedItem;
	
	public GameListDisplay(ListCache<?,?,GameDTO> listCache, GameCategory preferredCategory) throws Exception {
		super(listCache);
		this.preferredCategory = preferredCategory;
		this.preferredRankName = Example6FormatLibrary.formatGameCategory(preferredCategory);
		this.noSelectedItem = listCache.getSelectedIndex() < 0;
	}

	@Override
	protected GameDisplay formatRecord(GameDTO game, int index) {
		return new GameDisplay(game, preferredCategory);
	}
	
	public String getPreferredRankName() {
		return preferredRankName;
	}

	public boolean getNoSelectedItem() {
		return noSelectedItem;
	}

}